import 'package:flutter/material.dart';

class TitleButton extends StatelessWidget {
  final String title;

  final VoidCallback? onPressed;

  final _radius = const BorderRadius.all(Radius.circular(10.0));

  const TitleButton({Key? key, required this.title, required this.onPressed})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Material(
      borderRadius: _radius,
      child: Ink(
        decoration: BoxDecoration(
          color: Colors.blueAccent,
          borderRadius: _radius,
          //设置四周边框
          border: Border.all(width: 0.5, color: Colors.blueAccent),
        ),
        child: InkWell(
          //圆角设置,给水波纹也设置同样的圆角
          //如果这里不设置就会出现矩形的水波纹效果
          borderRadius: _radius,
          //设置点击事件回调
          onTap: onPressed,
          child: Container(
            //设置 child 居中
            alignment: Alignment.center,
            padding: const EdgeInsets.all(5),
            child: Text(
              title,
              style: const TextStyle(
                fontSize: 18.0,
                color: Colors.white,
              ),
            ),
          ),
        ),
      ),
    );
  }
}
